
 
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.DriverManager;
import java.sql.SQLException;
 
public class PostgresDB {
     
    private static String username = "webadmin", password = "sKbsiRvyPX";
    
     
    public static ResultSet sendQuery(String query) {
    	ResultSet rs=null;
    	Connection con = null;
		try {
			// Load the JDBC driver
			Class.forName("org.postgresql.Driver");
			// Get a connection to the database
			// Might throw an SQLException
			con = DriverManager.getConnection("jdbc:postgresql://localhost:5433/game", "postgres", "05229278");

			// The rest of the code goes here.
			Statement stmt = con.createStatement();
			rs = stmt.executeQuery(query);
			
		}
		catch (ClassNotFoundException e) {
			System.out.println(e);
		}
		catch (SQLException e) {
			System.out.println(e.getMessage());
		}
		finally {
			// Close the Connection to release the database resources immediately.
			try {
				if (con != null) con.close();
			}
			catch (SQLException ignored) {
				System.out.println(ignored);
			}
		}
		
		return rs; 
      
    }
}